package com.yyyzzz.service.impl;

import com.yyyzzz.DAO.impl.studentDaoimpl;
import com.yyyzzz.bean.Admin;
import com.yyyzzz.bean.Course;
import com.yyyzzz.bean.Student;
import com.yyyzzz.bean.StudentCourse;
import com.yyyzzz.service.studentService;
import com.yyyzzz.DAO.*;

import java.util.List;

public class studentServiceimpl implements studentService {
    studentDao studentDao1=new studentDaoimpl();

    @Override
    public List<StudentCourse> getAllCourse() {
        return studentDao1.selectAllCourse();
    }

    @Override
    public boolean addCourse(StudentCourse studentCourse) {
        if (studentDao1.insertCourse(studentCourse) != 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean isRegister(Student student) {
        if (studentDao1.insterstudent(student) == 0) {
            return false;
        } else {
            return true;
        }
    }
    @Override
    public boolean isLogin(Student student) {
        studentDao studentDao1 = new studentDaoimpl();
        Student student1 = studentDao1.selectAdminByNameAndPwd(student);
        if(student1 == null){
            return false;
        }
        return true;
    }
    @Override
    public List<Student> getAll() {
        // TODO Auto-generated method stub
        return studentDao1.selectAll();
    }

    @Override
    public boolean updateStudent(Student student) {
        if (studentDao1.updateStudent(student) == 0) {
            return false;
        }
        return true;
    }
    @Override
    public List selectOneById(String stuno) {
        if (studentDao1.selectOne(stuno) == null) {
            return null;
        }
        return studentDao1.selectOne(stuno);
    }
    @Override
    public int deleteByStuCourseid(String courseid) {
        return  studentDao1.deleteStuCourseByid(courseid);
    }
}

